home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Applications / MacPerl 5.0.3 / MacPerl Source ƒ / MacPerl5 / pod / modpods / Open2.pod < prev    next >
Encoding:
Text File  |  1994-12-26  |  1.1 KB  |  34 lines  |  [TEXT/MPS ]

  1. =head1 NAME
  2.  
  3. IPC::Open2, open2 - open a process for both reading and writing
  4.  
  5. =head1 SYNOPSIS
  6.  
  7.     use IPC::Open2;
  8.     $pid = open2('rdr', 'wtr', 'some cmd and args');
  9.       # or
  10.     $pid = open2('rdr', 'wtr', 'some', 'cmd', 'and', 'args');
  11.  
  12. =head1 DESCRIPTION
  13.  
  14. The open2() function spawns the given $cmd and connects $rdr for
  15. reading and $wtr for writing.  It's what you think should work 
  16. when you try
  17.  
  18.     open(HANDLE, "|cmd args");
  19.  
  20. open2() returns the process ID of the child process.  It doesn't return on
  21. failure: it just raises an exception matching C</^open2:/>.
  22.  
  23. =head1 WARNING 
  24.  
  25. It will not create these file handles for you.  You have to do this yourself.
  26. So don't pass it empty variables expecting them to get filled in for you.
  27.  
  28. Additionally, this is very dangerous as you may block forever.
  29. It assumes it's going to talk to something like B<bc>, both writing to
  30. it and reading from it.  This is presumably safe because you "know"
  31. that commands like B<bc> will read a line at a time and output a line at
  32. a time.  Programs like B<sort> that read their entire input stream first,
  33. however, are quite apt to cause deadlock.  See L<open3> for an alternative.
  34.